﻿CREATE VIEW dbo.KursTillfalleFull
AS
SELECT     dbo.KursTillfalle.Id AS KursTillfalleId, dbo.KursTillfalle.ValId, dbo.KursTillfalle.Kursdatum AS KursTillfalleDatum, dbo.KursTillfalle.Starttid AS KursTillfalleStarttid, 
                      dbo.KursTillfalle.Sluttid AS KursTillfalleSluttid, dbo.KursTillfalle.Adress AS KursTillfalleAdress, dbo.KursTillfalle.Sal AS KursTillfalleSal, 
                      dbo.KursTillfalle.Kursansvarig AS KursTillfalleKursansvarig, dbo.Kurs.Beskrivning AS KursTillfalleKursBeskrivning, dbo.Kurs.KursInfo AS KursTillfalleKursInfo, 
                      dbo.Person.Personnummer AS PersonPersonnummer, dbo.Person.Fornamn AS PersonFornamn, dbo.Person.Efternamn AS PersonEfternamn, 
                      dbo.Person.TelNr AS PersonTelNr, dbo.Person.MobTelNr AS PersonMobTelNr, dbo.Person.Epost AS PersonEpost, dbo.Person.Gatuadress AS PersonAdress, 
                      dbo.Person.PostNr AS PersonPostNr, dbo.Person.PostOrt AS PersonPostOrt, dbo.Person.Fritext AS PersonFritext, CASE (dbo.Person.Inaktiv) 
                      WHEN 0 THEN 'Aktiv' WHEN 1 THEN 'Inaktiv' END AS PersonStatus, CASE (dbo.Person.Inaktiv) 
                      WHEN 0 THEN '38A7CF73-0BFA-4F61-81E6-C1922F71F87D' WHEN 1 THEN '442F13BF-6ADA-43C1-BB88-828092B88C68' END AS PersonStatusID, 
                      dbo.PersonTyp.Benamning AS PersonTyp, dbo.PersonFull.PersonPersonnummer AS LararePersonnummer, dbo.PersonFull.PersonKonID AS LarareKonID, 
                      dbo.PersonFull.PersonKon AS LarareKon, dbo.PersonFull.PersonAlder AS LarareAlder, dbo.PersonFull.PersonFornamn AS LarareFornamn, 
                      dbo.PersonFull.PersonEfternamn AS LarareEfternamn, dbo.PersonFull.PersonTelNr AS LarareTelNr, dbo.PersonFull.PersonMobTelNr AS LarareMobTelNr, 
                      dbo.PersonFull.PersonEpost AS LarareEpost, dbo.PersonFull.PersonAdress AS LarareAdress, dbo.PersonFull.PersonPostNr AS LararePostNr, 
                      dbo.PersonFull.PersonPostOrt AS LararePostOrt, dbo.PersonFull.PersonFritext AS LarareFritext, dbo.PersonFull.PersonStatus AS LarareStatus, 
                      dbo.PersonFull.PersonStatusID AS LarareStatusID, dbo.PersonFull.PersonTyp AS LarareTyp, dbo.PersonFull.PersonTypID AS LarareTypId, 
                      dbo.KursTillfalle.Lokal AS KursTillfalleLokal
FROM         dbo.KursTillfalle LEFT OUTER JOIN
                      dbo.PersonFull ON dbo.KursTillfalle.ValId = dbo.PersonFull.ValId AND dbo.KursTillfalle.Kursansvarig = dbo.PersonFull.PersonId LEFT OUTER JOIN
                      dbo.Kurs ON dbo.KursTillfalle.KursId = dbo.Kurs.Id AND dbo.KursTillfalle.ValId = dbo.Kurs.ValId LEFT OUTER JOIN
                      dbo.PersonKursTillfalle ON dbo.PersonKursTillfalle.ValId = dbo.KursTillfalle.ValId AND dbo.PersonKursTillfalle.KursTillfalleId = dbo.KursTillfalle.Id AND 
                      dbo.PersonKursTillfalle.PersonId IS NOT NULL LEFT OUTER JOIN
                      dbo.Person ON dbo.PersonKursTillfalle.ValId = dbo.Person.ValId AND dbo.PersonKursTillfalle.PersonId = dbo.Person.Id LEFT OUTER JOIN
                      dbo.PersonPersonTyp ON dbo.Person.Id = dbo.PersonPersonTyp.PersonId AND dbo.Person.ValId = dbo.PersonPersonTyp.ValId LEFT OUTER JOIN
                      dbo.PersonTyp ON dbo.PersonPersonTyp.PersonTypId = dbo.PersonTyp.Id AND dbo.PersonPersonTyp.ValId = dbo.PersonTyp.ValId
GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'KursTillfalleFull';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'DisplayFlags = 280
            TopColumn = 3
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 24
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 2355
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 4485
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'KursTillfalleFull';








GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[44] 4[35] 2[12] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "KursTillfalle"
            Begin Extent = 
               Top = 30
               Left = 345
               Bottom = 377
               Right = 496
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PersonFull"
            Begin Extent = 
               Top = 466
               Left = 613
               Bottom = 668
               Right = 821
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Kurs"
            Begin Extent = 
               Top = 9
               Left = 37
               Bottom = 356
               Right = 188
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PersonKursTillfalle"
            Begin Extent = 
               Top = 111
               Left = 709
               Bottom = 397
               Right = 860
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Person"
            Begin Extent = 
               Top = 36
               Left = 966
               Bottom = 425
               Right = 1129
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PersonPersonTyp"
            Begin Extent = 
               Top = 72
               Left = 1212
               Bottom = 276
               Right = 1363
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PersonTyp"
            Begin Extent = 
               Top = 90
               Left = 1456
               Bottom = 357
               Right = 1607
            End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'KursTillfalleFull';







